package com.highveldsky.gwtdatabinding.client.controller;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.highveldsky.gwtdatabinding.client.service.CarServiceAsync;
import com.highveldsky.gwtdatabinding.shared.model.Car;

public class CarController implements CarUpdateListener {

	CarServiceAsync service;

	public CarController(CarServiceAsync service) {
		this.service = service;
	}
	
	public void updateCar(Car car) {
		service.updateCar(car, new AsyncCallback<Void>() {
			public void onSuccess(Void result) {
				Window.alert("Car updated :)");
			}
			public void onFailure(Throwable caught) {
				Window.alert("Car update failed :(");
			}
		});
	}

}
